package com.heima.comment.controller;

import com.heima.comment.service.CommentService;
import com.heima.model.comment.dtos.CommentDto;
import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 保存评论
     * @param commentDto
     * @return
     */
    @PostMapping("/save")
    private ResponseResult commentSave(@RequestBody CommentDto commentDto){
        return commentService.commentSave(commentDto);
    }

    /**
     * 点赞
     * @param dto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto){
        return commentService.like(dto);
    }

    /**
     * 查询评论列表
     * @param commentDto
     * @return
     */
    @PostMapping("/load")
    private ResponseResult load(@RequestBody CommentDto commentDto){
        return commentService.load(commentDto);
    }
}
